<?php
namespace app\admin\controller\account;

use app\admin\model\AuthRule;
use think\Db;

use app\common\controller\SysCommon;
use think\route\AliasRule;

class Rule extends SysCommon
{
    protected $model = '';

    public function initialize()
    {
        parent::initialize();
        $this->model = new AuthRule();

    }
    public function index()
    {
        if(request()->isPost()){
            //用户表的实例化
            $post = input('post.');
            $list  = $this->model->getListAll();
            return ajax_return('0','角色列表',count($list),$list);

        }else{
            //查询一级权限组
            $where[] = ['type','eq',1];
            $rule  =  $this->model->selectList($where,"id,title,group_name",'sort desc');
            //查询一级权限组
            $where_two[] = ['type','eq',2];
            $rule_two  =  $this->model->selectList($where_two,"id,title,group_name,sub_module_name,rule_val",'pid,sort desc');
            $this->assign("rule",$rule);
            $this->assign("rule_two",$rule_two);
            return $this->fetch();
        }
    }
}